﻿<body>
<div id="longDesc">
<span style="font-family:Calibri; font-size:medium">
<h1 style="font-family:Calibri Light; color:#2e74b5; font-size:large">Introduction</h1>
<p>The<strong> xDSCResourceDesigner</strong> module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is 
a tool to author PowerShell DSC Resources and produced by the PowerShell Team.This tool makes writing resources a breeze and ensure that all the rules which a DSC resource must conform to are met.</p>
<p><strong>All of the functions/cmdlets in the Resource Designer Tool are provided AS IS, and are not supported through any Microsoft standard support program 
or service. The "x" in xDSCResourceDesigner stands for experimental</strong>, which means that this tool will be <strong>fix forward</strong> 
and monitored by the module owner(s).</p>
<p>Please leave comments, feature requests, and bug reports in the Q &amp; A tab for this module.</p>
<p>If you would like to modify <strong>xDSCResourceDesigner</strong> module, feel free. When modifying, please update the module name and the function names (instructions below). As specified in the license, you may copy or modify this tool as long as they are used on the Windows Platform.</p>
<p>For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the
<a href="http://blogs.msdn.com/b/powershell/"><span style="color:#0000ff">PowerShell Blog</span></a> (</span><a href="http://blogs.msdn.com/b/powershell/archive/2013/11/01/configuration-in-a-devops-world-windows-powershell-desired-state-configuration.aspx"><span style="color:#0000ff">this</span></a> is a good starting point). There are 
also great community resources, such as <a href="http://powershell.org/wp/tag/dsc/"><span style="color:#0000ff">PowerShell.org</span></a>, or
<a href="http://www.powershellmagazine.com/tag/dsc/"><span style="color:#0000ff">PowerShell Magazine</span></a>. For more information on the DSC Resource Kit, check out 
<a href="http://go.microsoft.com/fwlink/?LinkID=389546"><span style="color:#0000ff">this blog post</span></a>.<br></p>

<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Installation</h1>
<p>To install <strong >xDSCResourceDesigner</strong> module </p>
<ul style="list-style-type:disc; direction:ltr">
<li>Unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder</li>
</ul>
<p>To confirm installation:<br></p>
<ul style="list-style-type:disc; direction:ltr">
<li>Run <strong>Get-Module -ListAvailable</strong> to see that <strong>xDSCResourceDesigner</strong> is among the modules listed<br></li>
</ul>

<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Requirements</h1>
<p>This module requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012R2). To easily use PowerShell 4.0 on older operating systems,
<a href="http://www.microsoft.com/en-us/download/details.aspx?id=40855"><span style="color:#0000ff">install WMF 4.0</span></a>. Please read the installation instructions 
that are present on both the download page and the release notes for WMF 4.0.</p>

<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Description</h1>
<p>The <strong >xDSCResourceDesigner </strong> module exposes 6 functions: <strong >New-xDscResourceProperty, New-xDscResource, Update-xDscResource, Test-xDscResource, Test-xDscSchema and Import-xDscSchema </strong>. These uses of these functions are given below.</p>

<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Details</h1>
<p><strong>xDSCResourceDesigner</strong> module exposes the following functions:</p>
<ul style="list-style-type:disc; direction:ltr">
<li>
    <strong>New-xDscResourceProperty</strong>: <span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>For creating a property for the resource
</li>
<li>
    <strong >New-xDscResource</strong>: <span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>for creating the actual resource containing the schema and module skeleton
</li>
<li>
    <strong >Update-xDscResource</strong>: for updating an existing resource with new properties
</li>
<li>
    <strong >Test-xDscResource</strong>: <span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>for testing whether an existing resource conforms to the rules required by DSC
</li>
<li>
    <strong>Test-xDscSchema</strong>: <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>for testing whether an existing schema (schema.mof) conforms to the rules required by DSC
</li>
<li>
    <strong>Import-xDscSchema</strong>: <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>for getting the properties in a schema returned as a hashtable
</li>
</ul>

<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Renaming Requirements</h1>
<p>When making changes to these resources, we suggest the following practice:</p>
<ol style="list-style-type:decimal; direction:ltr">
<li>
    Update the following names by replacing MSFT with your company/community name and replacing the <strong>"x"</strong> with <strong>"c"</strong> (short for "Community") or another prefix of your choice:
<ul>
<li>
    <strong>Module name (ex: xDSCResourceDesigner</strong> becomes <strong>cDSCResourceDesigner</strong>)
</li>
<li>
    <strong>Function name (ex: New-xDscResource</strong> becomes <strong>New-cDscResource</strong>)
</li>
</ul>
</li>
<li>
    Update module and metadata information in the module manifest
</li>
<li>
    Update any scripts that uses this module
</li>
</ol>
<p><em>We reserve resource and module names without prefixes ("x" or "c") for future use (e.g. "xDSCResourceDesigner" or "DSCResourceDesigner"). If the next version of Windows Server ships with a "DSCResourceDesigner" module, we don't want to break any scripts that use any community modifications. Please keep a prefix such as "c" on all community modifications.</em></p>


<h1 style="color:#2e74b5; font-family:Calibri Light; font-size:large">Versions</h1>
<p>1.0.0.0</p>
<ul style="list-style-type:disc; direction:ltr">
<li>
    Initial release with the following module
<ul style="list-style-type:circle">
<li>
    xDSCResourceDesigner  
</li>
</ul>
</ul>
<p>1.1.1.1</p>
    <ul>
        <li>
            Metadata updates.
        </li>
    </ul>
<p>1.1.2</p>
    <ul>
        <li>
            Ignore -WhatIf and -Confirm internal parameters to suppress false errors when Set-TargetResource declares
            [CmdletBinding(SupportsShouldProcess=$true)]
        </li>
    </ul>
    <p><span style="font-family:Calibri; font-size:medium">&nbsp;</span></p>
    <p>&nbsp;</p>
    <h1 style="margin-bottom:0pt; font-family:Calibri Light; color:#2e74b5; font-size:large">
        Example: Create a Sample DSC ADUser Resource
    </h1>
    <p>This example creates a ADUser DSC resource.</p>
    <div class="scriptcode">
        <div class="pluginEditHolder" plugincommand="mceScriptCode">
            <div class="title"><span>PowerShell</span></div>
            <div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span></div>
            <span class="hidden">powershell</span>
<pre class="hidden">&lt;#
Create a ADUser DSC Resource with following properties
UserName: Name of the ADUser. This is a  key property for the resource that uniquely identify an instance.
Password: Password of the user. Can be used to update an existing user password.
DomainAdminstratorCredential: Credential of the Domain Administrator in which user account will be created.
Ensure: Whether an user account should be created or deleted. This can only take two values: &lsquo;Present&rsquo; and &lsquo;Absent&rsquo;.
#&gt;
$UserName = New-xDscResourceProperty -Name UserName -Type String -Attribute Key
$Password = New-xDscResourceProperty -Name Password -Type PSCredential -Attribute Write 
$DomainCredential = New-xDscResourceProperty -Name DomainAdministratorCredential -Type PSCredential -Attribute Write 
$Ensure = New-xDscResourceProperty -Name Ensure -Type String -Attribute Write -ValidateSet &quot;Present&quot;, &quot;Absent&quot; 
#Now create the resource
New-xDscResource -Name Contoso_cADUser -Property $UserName, $Password, $DomainCredential, $Ensure  -Path 'C:\Program Files\WindowsPowerShell\Modules\xActiveDirectory'  
</pre>
            <div class="preview">
<pre class="powershell"><span class="powerShell__mlcom">&lt;#&nbsp;
Create&nbsp;a&nbsp;ADUser&nbsp;DSC&nbsp;Resource&nbsp;with&nbsp;following&nbsp;properties&nbsp;
UserName:&nbsp;Name&nbsp;of&nbsp;the&nbsp;ADUser.&nbsp;This&nbsp;is&nbsp;a&nbsp;&nbsp;key&nbsp;property&nbsp;for&nbsp;the&nbsp;resource&nbsp;that&nbsp;uniquely&nbsp;identify&nbsp;an&nbsp;instance.&nbsp;
Password:&nbsp;Password&nbsp;of&nbsp;the&nbsp;user.&nbsp;Can&nbsp;be&nbsp;used&nbsp;to&nbsp;update&nbsp;an&nbsp;existing&nbsp;user&nbsp;password.&nbsp;
DomainAdminstratorCredential:&nbsp;Credential&nbsp;of&nbsp;the&nbsp;Domain&nbsp;Administrator&nbsp;in&nbsp;which&nbsp;user&nbsp;account&nbsp;will&nbsp;be&nbsp;created.&nbsp;
Ensure:&nbsp;Whether&nbsp;an&nbsp;user&nbsp;account&nbsp;should&nbsp;be&nbsp;created&nbsp;or&nbsp;deleted.&nbsp;This&nbsp;can&nbsp;only&nbsp;take&nbsp;two&nbsp;values:&nbsp;&lsquo;Present&rsquo;&nbsp;and&nbsp;&lsquo;Absent&rsquo;.&nbsp;
#&gt;</span>&nbsp;
&nbsp;
<span class="powerShell__variable">$UserName</span>&nbsp;=&nbsp;New<span class="powerShell__operator">-</span>xDscResourceProperty&nbsp;<span class="powerShell__operator">-</span>Name&nbsp;UserName&nbsp;<span class="powerShell__operator">-</span><span class="powerShell__alias">Type</span>&nbsp;String&nbsp;<span class="powerShell__operator">-</span>Attribute&nbsp;Key&nbsp;
<span class="powerShell__variable">$Password</span>&nbsp;=&nbsp;New<span class="powerShell__operator">-</span>xDscResourceProperty&nbsp;<span class="powerShell__operator">-</span>Name&nbsp;Password&nbsp;<span class="powerShell__operator">-</span><span class="powerShell__alias">Type</span>&nbsp;PSCredential&nbsp;<span class="powerShell__operator">-</span>Attribute&nbsp;Write&nbsp;&nbsp;
<span class="powerShell__variable">$DomainCredential</span>&nbsp;=&nbsp;New<span class="powerShell__operator">-</span>xDscResourceProperty&nbsp;<span class="powerShell__operator">-</span>Name&nbsp;DomainAdministratorCredential&nbsp;<span class="powerShell__operator">-</span><span class="powerShell__alias">Type</span>&nbsp;PSCredential&nbsp;<span class="powerShell__operator">-</span>Attribute&nbsp;Write&nbsp;&nbsp;
<span class="powerShell__variable">$Ensure</span>&nbsp;=&nbsp;New<span class="powerShell__operator">-</span>xDscResourceProperty&nbsp;<span class="powerShell__operator">-</span>Name&nbsp;Ensure&nbsp;<span class="powerShell__operator">-</span><span class="powerShell__alias">Type</span>&nbsp;String&nbsp;<span class="powerShell__operator">-</span>Attribute&nbsp;Write&nbsp;<span class="powerShell__operator">-</span>ValidateSet&nbsp;<span class="powerShell__string">&quot;Present&quot;</span>,&nbsp;<span class="powerShell__string">&quot;Absent&quot;</span>&nbsp;&nbsp;
&nbsp;
<span class="powerShell__com">#Now&nbsp;create&nbsp;the&nbsp;resource</span>&nbsp;
New<span class="powerShell__operator">-</span>xDscResource&nbsp;<span class="powerShell__operator">-</span>Name&nbsp;Contoso_cADUser&nbsp;<span class="powerShell__operator">-</span>Property&nbsp;<span class="powerShell__variable">$UserName</span>,&nbsp;<span class="powerShell__variable">$Password</span>,&nbsp;<span class="powerShell__variable">$DomainCredential</span>,&nbsp;<span class="powerShell__variable">$Ensure</span>&nbsp;&nbsp;<span class="powerShell__operator">-</span>Path&nbsp;<span class="powerShell__string">'C:\Program&nbsp;Files\WindowsPowerShell\Modules\xActiveDirectory'</span>&nbsp;&nbsp;&nbsp;
</pre>
            </div>
        </div>
    </div>
    <h1 style="margin-bottom:0pt; font-family:Calibri Light; color:#2e74b5; font-size:large">
        Example: Test an Incorrect Resource Definition
    </h1>
    <div id="longDesc">This example will use Test-xDscSchema function to check if the resource definition is correct or not</div>
    <div>
        <div class="scriptcode">
            <div class="pluginEditHolder" plugincommand="mceScriptCode">
                <div class="title"><span>PowerShell</span></div>
                <div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span></div>
                <span class="hidden">powershell</span>
<pre class="hidden">&lt;#
Suppose you have the following schema (named buggy.schema.mof):
[ClassVersion(&quot;1.0.0.0&quot;), FriendlyName(&quot;&quot;)]
class Contoso_cADUser : OMI_BaseResource
{
       [Key] String UserName;
       [Write, ValueMap{&quot;Present&quot;,&quot;Absent&quot;}, Values{&quot;Present&quot;,&quot;Absent&quot;}] String Ensure;
};
#&gt;
# This reports that the schema is buggy.
Test-xDscSchema -Path .\buggy.schema.mof</pre>
                <div class="preview">
<pre class="powershell"><span class="powerShell__mlcom">&lt;#&nbsp;
Suppose&nbsp;you&nbsp;have&nbsp;the&nbsp;following&nbsp;schema&nbsp;(named&nbsp;buggy.schema.mof):&nbsp;
[ClassVersion(&quot;1.0.0.0&quot;),&nbsp;FriendlyName(&quot;&quot;)]&nbsp;
class&nbsp;Contoso_cADUser&nbsp;:&nbsp;OMI_BaseResource&nbsp;
{&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Key]&nbsp;String&nbsp;UserName;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Write,&nbsp;ValueMap{&quot;Present&quot;,&quot;Absent&quot;},&nbsp;Values{&quot;Present&quot;,&quot;Absent&quot;}]&nbsp;String&nbsp;Ensure;&nbsp;
};&nbsp;
#&gt;</span>&nbsp;
&nbsp;
<span class="powerShell__com">#&nbsp;This&nbsp;reports&nbsp;that&nbsp;the&nbsp;schema&nbsp;is&nbsp;buggy.</span>&nbsp;
Test<span class="powerShell__operator">-</span>xDscSchema&nbsp;<span class="powerShell__operator">-</span>Path&nbsp;.\buggy.schema.mof</pre>
                </div>
            </div>
        </div>
    </div>
    <h1 style="margin-bottom:0pt; font-family:Calibri Light; color:#2e74b5; font-size:large">
        Example: Updates an Existing Resource
    </h1>
    <div id="longDesc">This example will use Update-xDscResource function to update an already existing resource properties</div>
    <div>
        <div class="scriptcode">
            <div class="pluginEditHolder" plugincommand="mceScriptCode">
                <div class="title"><span>PowerShell</span></div>
                <div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span></div>
                <span class="hidden">powershell</span>
<pre class="hidden">#Assume, you want to add an additional property called LastLogOn on existing Constoso_cADUser resource
$lastLogOn = New-xDscResourceProperty -Name LastLogOn -Type Hashtable -Attribute Read -Description &quot;Returns the user last log on time&quot; 
#Update the existing resource
Update-xDscResource -Name 'Contoso_cADUser' -Property $UserName, $Password, $DomainCredential, $Ensure, $lastLogOn -Force</pre>
                <div class="preview">
<pre class="powershell"><span class="powerShell__com">#Assume,&nbsp;you&nbsp;want&nbsp;to&nbsp;add&nbsp;an&nbsp;additional&nbsp;property&nbsp;called&nbsp;LastLogOn&nbsp;on&nbsp;existing&nbsp;Constoso_cADUser&nbsp;resource</span>&nbsp;
&nbsp;
<span class="powerShell__variable">$lastLogOn</span>&nbsp;=&nbsp;New<span class="powerShell__operator">-</span>xDscResourceProperty&nbsp;<span class="powerShell__operator">-</span>Name&nbsp;LastLogOn&nbsp;<span class="powerShell__operator">-</span><span class="powerShell__alias">Type</span>&nbsp;Hashtable&nbsp;<span class="powerShell__operator">-</span>Attribute&nbsp;Read&nbsp;<span class="powerShell__operator">-</span>Description&nbsp;<span class="powerShell__string">&quot;Returns&nbsp;the&nbsp;user&nbsp;last&nbsp;log&nbsp;on&nbsp;time&quot;</span>&nbsp;&nbsp;
&nbsp;
<span class="powerShell__com">#Update&nbsp;the&nbsp;existing&nbsp;resource</span>&nbsp;
Update<span class="powerShell__operator">-</span>xDscResource&nbsp;<span class="powerShell__operator">-</span>Name&nbsp;<span class="powerShell__string">'Contoso_cADUser'</span>&nbsp;<span class="powerShell__operator">-</span>Property&nbsp;<span class="powerShell__variable">$UserName</span>,&nbsp;<span class="powerShell__variable">$Password</span>,&nbsp;<span class="powerShell__variable">$DomainCredential</span>,&nbsp;<span class="powerShell__variable">$Ensure</span>,&nbsp;<span class="powerShell__variable">$lastLogOn</span>&nbsp;<span class="powerShell__operator">-</span>Force</pre>
                </div>
            </div>
        </div>
        <div class="endscriptcode">&nbsp;</div>
    </div>
    <p>&nbsp;</p>

</span>
</div>
</body>

